	<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<title>实名认证</title>
		<link rel="stylesheet" href="../css/mui.min.css" />
		<link rel="stylesheet" href="../css/main.css" />
		<link rel="stylesheet" href="../css/mui.picker.css" />
		<link rel="stylesheet" href="../css/mui.poppicker.css" />
		<link rel="stylesheet" href="../css/feedback.css" />
		<style>
			.mui-content {
				margin-top: 0.08rem;
				font-size: 0.2916rem;
			}
			
			#zhaoxiang {
				height: 2rem;
			}
			
			#zhaoxiang.mui-table-view-cell {
				padding-top: 0.5rem;
				height: 130px;
			}
			
			#zhaoxiang a span:after {
				top: 40%;
			}
			
			#head_image {
				width: 90px;
				height: 90px;
				border-radius: 50px;
				margin-top: 10px;
			}
			
			.head {
				margin-top: -0.6rem;
				margin-right: 15px;
			}
			
			.mui-content>.mui-table-view:first-child {
				margin-bottom: 0.08rem;
			}
			
			#libiao li {
				height: 1.0rem;
				padding-top: 0.25rem;
			}
			
			#libiao li span {
				margin-right: 20px;
				font-size: 14px;
			}
			
			.qianming {
				width: 50%;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
				text-align: right;
			}
			
			.mui-table-view-cell:after {
				left: 0;
			}
			
			.mui-navigate-right:after {
				font-size: 25px;
				right: 5px;
			}
			
			.mui-table-view-cell a {
				color: #424242;
				font-size: 15px;
			}
			
			.mui-table-view-cell span {
				color: #999999;
			}
			
			#forward {
				font-size: 0.3124rem;
				font-weight: 400;
			}
			
			#male {
				color: #00c0ff;
				height: 1.1rem;
			}
			
			#female {
				color: #ff0072;
				height: 1.1rem;
			}
			
			#male div,
			#female div {
				background: url(../../../images/tubiao2.png) no-repeat;
			}
			
			.redword {
				color: #FF3300 !important;
			}
			
			.shengfen_upload {
				max-width: 100%;
				background: #FFFFFF;
				height: 200px;
				padding-top: 70px;
			}
			
			.mui-content-padded a {
				margin: 3px;
				width: 50px;
				height: 50px;
				display: block;
				text-align: center;
				background-color: #fff;
				border: 1px solid #ddd;
				border-radius: 25px;
				background-clip: padding-box;
				margin: 0 auto;
			}
			
			.mui-content-padded a .mui-icon {
				margin-top: 12px;
				color: #000000;
				margin-top: -7px;
				margin-left: -6px;
			}
			
			.mui-icon {
				font-size: 60px;
			}
			
			.upload_word {
				margin: 10px auto;
				display: block;
				text-align: center;
			}
			
			.shenfen_card,
			.sign_name {
				width: 70% !important;
				height: 20px !important;
				font-size: 14px;
			}
			
			.error_shenfen_card {
				border: 1px dotted rgba(0, 0, 0, 0) !important;
			}
			
			.right_shenfen_card {
				border: 1px solid rgba(0, 0, 0, 0) !important;
			}
			
			.tishi {
				width: 93%;
				font-size: 13px;
				color: #999999;
				margin: auto;
				/*input[type="number"] {
				border: 1px solid rgba(0, 0, 0, 0) !important;
				/*line-height: 30px;*/
			}
			
			html,
			body {
				height: 100%;
				margin: 0px;
				padding: 0px;
				/*overflow: hidden;*/
				/*-webkit-touch-callout: none;*/
				/*-webkit-user-select: none;*/
			}
			
			.mui-content {
				height: 100%;
				overflow: auto;
			}
			
			#showUserPicker {
				float: inherit;
				width: 87%;
				padding: 10px 15px;
				background-color: #FFF !important;
				color: #424242;
			}
			
			input[type=color],
			input[type=date],
			input[type=datetime-local],
			input[type=datetime],
			input[type=email],
			input[type=month],
			input[type=number],
			input[type=password],
			input[type=search],
			input[type=tel],
			input[type=text],
			input[type=time],
			input[type=url],
			input[type=week],
			select,
			textarea {
				line-height: 21px;
				width: 100%;
				height: 40px;
				margin-bottom: 15px;
				padding: 10px 15px;
				-webkit-user-select: text;
				border: none;
				border-radius: 3px;
				outline: 0;
				background-color: #fff;
				-webkit-appearance: none;
			}
			
			.doctor_one {
				background-color: #ffffff;
				border-bottom: 1px solid #eeeeee;
			}
			
			.content {
				background-color: #ffffff;
			}
			
			.qs-image-div {
				padding: 10px;
				width: 100%;
				text-align: center;
			}
			
			.qs-image-item {
				display: block;
				height: 100px;
			}
			#userPhone {
				width: 50%;
				padding-bottom: 8%;
				float: right;
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">实名认证</h1>
		</header>
		<div class="mui-content content">
			<form action="">
				<ul class="mui-table-view" id="libiao">
					<li class="mui-table-view-cell">
						<a id="">手机号：<div id="userPhones" style="float: right;"></div></a>
					</li>
					<li class="mui-table-view-cell doctor_one">
						<a>性&nbsp;&nbsp;&nbsp;&nbsp;别：<span class="mui-pull-right">
						<label>男</label>
						<input id="leixingradio" name="leixingradio" class="leixingradio" type="radio" value="1" checked="checked">&nbsp;&nbsp;&nbsp;&nbsp;
						<label>女</label>
						<input id="leixingradio" name="leixingradio" class="leixingradio" type="radio" value="0"></span>
						</a>
					</li>
					<li class="mui-table-view-cell doctor_one">
						<a>职&nbsp;&nbsp;&nbsp;&nbsp;业：<span class="mui-pull-right">
						<label>护士</label>
						<input id="zhiyeradio" name="zhiyeradio" class="zhiyeradio" type="radio" value="nurse" checked="checked">
						<label>医生</label>
						<input id="zhiyeradio" name="zhiyeradio" class="zhiyeradio" type="radio" value="doctor"></span>
						</a>
					</li>

					<li class="mui-table-view-cell doctor_one">
						<a id="signatureLi">真实姓名：<input type="text" class="sign_name error_shenfen_card mui-input" placeholder="请输入您的姓名" id="sign_name"><span class="mui-icon mui-icon-checkmarkempty duihao" style="font-size: 24px; display: none;"></span> </a>
					</li>
					<li class="mui-table-view-cell doctor_one">
						<a id="signatureLi">身份证号：<input type="text" class="shenfen_card error_shenfen_card" placeholder="请输入您的身份证号" id="shenfen_card"><span class="mui-icon mui-icon-checkmarkempty duihao" style="font-size: 24px; display: none;"></span></a>
					</li>

					<li class="mui-table-view-cell" style="position:relative;">
						<a id="showUserPicker">医&nbsp;&nbsp;&nbsp;&nbsp;院：<input type="text" class="shenfen_card error_shenfen_card" placeholder="" id="hospitalText" readonly="readonly"><span class="mui-icon mui-icon-checkmarkempty duihao" style="font-size: 24px; display: none;"></span></a>
						<label class="labelR" id='showUserPicker_img' style="position:absolute;top:28%;left:85%"><img src="../images/exit/xz.png" /></label>
					</li>
				</ul>
			</form>
			<div class="mui-table-view-cell ">
				<a id="signatureLi">身份证正反面照片上传<span class="redword">&nbsp;&nbsp;(3个工作日内通知审核结果)</span></a>
			</div>
			<div class="mui-content-padded doctor_one">
				<div class="mui-row">
					<div class="mui-col-sm-6 mui-col-xs-6" style="text-align:center">
						<div class="qs-image-div">
							<img class="qs-image-item" id="idimg" src="../images/wode/sfzz.png">
							<input id='idimgPath' type="hidden" class="mui-input">
						</div>

					</div>
					<div class="mui-col-sm-6 mui-col-xs-6" style="text-align:center">
						<div class="qs-image-div">
							<img class="qs-image-item" id="idimgback" src="../images/wode/sfzf.png">
							<input id='idimgbackPath' type="hidden" class="mui-input">
						</div>
					</div>
				</div>

				<div id="feedback" class="mui-page feedback">
					<div class="mui-page-content">
						<div class="tishi">
							本人承诺以上信息的真实性，如若不填或填写虚假信息引发的结果 由本人自负。未实名认证者，不能使用系统的订单功能。
						</div>
					</div>
				</div>
			</div>

			<div class="mui-table-view-cell ">
				<a id="signatureLi">医护资质照片上传<span class="redword">&nbsp;&nbsp;(3个工作日内通知审核结果)</span></a>
			</div>
			<div class="mui-content-padded doctor_one">
				<div id="feedback" class="mui-page feedback">
					<div class="mui-page-content">
						<div id='image-list' class="row image-list"></div>
						<div class="tishi">
							本人承诺以上信息的真实性，如若不填或填写虚假信息引发的结果 由本人自负。未实名认证者，不能使用系统的订单功能。
						</div>
					</div>
				</div>
			</div>

			<div class="mui-content-padded">
				<button id='send_ok' class="mui-btn mui-btn-block mui-btn-warning ">确定</button>
				<button id='enter_main' class="mui-btn mui-btn-block mui-btn-warning">进入首页</button>
			</div>
		</div>

		<script src="../js/mui.min.js"></script>
		<script src="../js/xiangyingshi.js"></script>
		<script type="text/javascript" src="../js/constants.js"></script>
		<script type="text/javascript" src="../js/jquery-3.1.1.min.js"></script>
		<script type="text/javascript" src="../js/mui.picker.js"></script>
		<script type="text/javascript" src="../js/mui.poppicker.js"></script>
		<script type="text/javascript" src="../js/exif.js"></script>
		<script type="text/javascript" src="../js/mobileBUGFix.mini.js"></script>
		<script type="text/javascript" src="../plugs/qs/qs.feedback.js"></script>
		<script type="text/javascript" src="../js/sharemethods.js"></script>
		<script>
			var user = JSON.parse(localStorage.getItem("USER"));
			var idImgPath = "";
			var imgurl = serverAddress + uploadImgFileUrl;
			mui.plusReady(function() {
				
				qs.initImageList({
					id: 'image-list'
				});
				mui(".mui-content").on("click", ".qs-image-item", function() {
					var id = this.id
					uploadImg(imgurl, function(imgPath, data) {
						if(data.result == 'success') {
							document.getElementById(id).src = imgPath;
							document.getElementById(id + 'Path').value = data.obj.path;
						} else {
							mui.toast("文件上传失败");
						}
					});
				});
			});

			var hospital, username, leixing, nameinput, shenfen_cardinput, shenfen_img = [];
			mui.plusReady(function() {

				mui.init({
					keyEventBind: {
						backbutton: true //打开back按键监听
					},
					beforeback: function() {
						//返回true，继续页面关闭逻辑  
						mui.back;
						//获得列表界面的webview
						var list = plus.webview.getWebviewById("subpages/tab-webview-subpage-my.html");
						//触发列表界面的自定义事件（refresh）,从而进行数据刷新
						mui.fire(list, 'refresh');
						//返回true，继续页面关闭逻辑
						return true;
					}
				});
				plus.webview.currentWebview().setStyle({
					softinputMode: "adjustResize" // 弹出软键盘时自动改变webview的高度
				});
				if(plus.navigator.isImmersedStatusbar()) { // 兼容immersed状态栏模式
					// 获取状态栏高度并根据业务需求处理，这里重新计算了子窗口的偏移位置
					topoffset = (Math.round(plus.navigator.getStatusbarHeight()) + 45) + 'px';
					document.querySelector("header").style.height = topoffset;
					document.querySelector("header").style.paddingTop = "20px";
					document.querySelector(".mui-bar-nav~.mui-content").style.paddingTop = topoffset;
				}

				// 加载完毕后关闭等待框，并展示页面
				var currentView = plus.webview.currentWebview();
				currentView.show('slide-in-right', 200);
				plus.nativeUI.closeWaiting();
				
				var self = plus.webview.currentWebview();
			  var phone = self.phone;
			  $("#userPhones").html(phone);
			 
				if(username == null) {
					var self = plus.webview.currentWebview();
					username = self.USER_TEL;
				}

				var id = localStorage.getItem("TOKENID");
				if(id == null) {
					var self = plus.webview.currentWebview();
					id = self.USER_ID;
				}

				$("#send_ok").click(function(e) {
					var  phone = $('#userPhone').val();
					nameinput = $("#sign_name").val().trim();
					localStorage.setItem("GEREN_NAME", nameinput);
					shenfen_cardinput = $(".shenfen_card").val().trim();
					leixing = localStorage.getItem("leixing") == null ? "0" : localStorage.getItem('leixing');
					zhiye = localStorage.getItem("zhiye") == null ? "nurse" : localStorage.getItem('zhiye');
					//判断姓名
					if(nameinput == null || nameinput == '') {
						mui.toast("请填写姓名");
						return false;
					}
					//判断身份证号码
					if(shenfen_cardinput == null || isCardID(shenfen_cardinput) != true) {
						mui.toast("身份证号码错误");
						return false;
					}
					//判断是否输入医院
					if(hospital == null || hospital == '') {
						mui.toast("请输入医院");
						return false;
					}
					//判断是否上传身份证照片
					if(!$("#idimgPath").val()){
						mui.toast("请上传图片");
						return false;
					} 
					if(!$("#idimgbackPath").val()){
						mui.toast("请上传图片");
						return false;
					} 
					//判断图片上传 是否成功
					if($$.getImageFilesPath("image-list").length == 0){
						mui.toast("请上传图片");
						return false;
					} 
					
					

					function success(data) {
						//服务器返回响应，根据响应结果，分析是否登录成功；
						//console.log("111" + JSON.stringify(data));
						if(data.result = "success") {
							mui.toast("您已经提交实名认证，请等待审核！");
							var main = plus.webview.getLaunchWebview();
							// 获取所有Webview窗口
							var curr = plus.webview.currentWebview();
							var wvs = plus.webview.all();
							for(var i = 0, len = wvs.length; i < len; i++) {
								//关闭除setting页面外的其他页面
								if(wvs[i].getURL() == curr.getURL())
									continue;
								plus.webview.close(wvs[i]);
							}
							//打开login页面后再关闭setting页面
							plus.webview.open("../index.html", "slide-in-right", 300);
							plus.nativeUI.showWaiting();
							curr.close();
						}
					}

					var data = {
						idfaceavatar: $('#idimgPath').val(),  // 身份证上传的2个图片的验证的值
						idbackavatar: $('#idimgbackPath').val(),  // 身份证上传的2个图片的验证的值
						imgzz: $$.getImageFilesPath("image-list"),  // 医护资质的上传路径的 验证的数据
						idnumber: $('#shenfen_card').val(),
						name: nameinput,
						hid: hospital,
						sex: leixing,
						dtype: zhiye,
					};
					commonHttpUtils(authenticationUrl, 'PUT', data, success, error);

					// 刷新父页面
					var list = plus.webview.currentWebview().opener();
					//触发列表界面的自定义事件（refresh）,从而进行数据刷新  
					mui.fire(list, 'refresh');
				});
				$("#enter_main").click(function() {
					var main = plus.webview.getLaunchWebview();
					//if(mui.os.ios || mui.os.ipad || mui.os.iphone) {
					// 获取所有Webview窗口
					var curr = plus.webview.currentWebview();
					var wvs = plus.webview.all();
					for(var i = 0, len = wvs.length; i < len; i++) {
						//关闭除setting页面外的其他页面
						if(wvs[i].getURL() == curr.getURL())
							continue;
						plus.webview.close(wvs[i]);
					}
					//打开login页面后再关闭setting页面
					plus.webview.open("../index.html");
					curr.close();
				});
			});
			$(".leixingradio").click(function() {
				leixing = $(this).val();
				localStorage.setItem("leixing", leixing);
			});
			$(".zhiyeradio").click(function() {
				zhiye = $(this).val();
				localStorage.setItem("zhiye", zhiye);
			});
			

			function isCardID(sId) {
				var iSum = 0;
				var info = "";
				if(!/^\d{17}(\d|x)$/i.test(sId)) return "你输入的身份证长度或格式错误";
				sId = sId.replace(/x$/i, "a");
				if(aCity[parseInt(sId.substr(0, 2))] == null) return "你的身份证地区非法";
				sBirthday = sId.substr(6, 4) + "-" + Number(sId.substr(10, 2)) + "-" + Number(sId.substr(12, 2));
				var d = new Date(sBirthday.replace(/-/g, "/"));
				if(sBirthday != (d.getFullYear() + "-" + (d.getMonth() + 1) + "-" + d.getDate())) return "身份证上的出生日期非法";
				for(var i = 17; i >= 0; i--) iSum += (Math.pow(2, i) % 11) * parseInt(sId.charAt(17 - i), 11);
				if(iSum % 11 != 1) return "你输入的身份证号非法";
				//aCity[parseInt(sId.substr(0,2))]+","+sBirthday+","+(sId.substr(16,1)%2?"男":"女");//此次还可以判断出输入的身份证号的人性别
				return true;
			}

			//获取医院列表
			var userPicker = new mui.PopPicker();
			var url = serverAddress + "/api/patient/gethosnames";
			mui.ajax(url, {
				data: {},
				dataType: 'json', //服务器返回json格式数据
				type: 'get', //HTTP请求类型
				timeout: 180000, //超时时间设置为30秒；
				success: function(data) {
					//服务器返回响应，根据响应结果，分析是否登录成功；
					console.log(JSON.stringify(data));
					userPicker.setData(data);
				},
				error: function(xhr, type, errorThrown) {
					//异常处理；
					mui.toast('获取医院网络超时，请稍后再试！');
					plus.nativeUI.closeWaiting();
				}
			});
			var showUserPicker = document.getElementById("showUserPicker");
			var showUserPickerButton = document.getElementById('showUserPicker_img');
			var userResult = document.getElementById('userResult');
			showUserPickerButton.addEventListener("tap", function(event) {
				userPicker.show(function(items) {
					console.log(items[0].text)
					showUserPicker.value = items[0].text;
					$('#hospitalText').val(items[0].text);
					hospital = items[0].value;
				});
			}, false);
		</script>
	</body>

</html>